﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using MYA_WPF.Utils;
using MYA_WPF.Model;

namespace MYA_WPF
{
    /// <summary>
    /// Logique d'interaction pour MainWindow.xaml
    /// </summary>
    public partial class MainWindow : Window
    {
        public MainWindow()
        {
            InitializeComponent();

        }
        protected override void OnInitialized(EventArgs e)
        {
            base.OnInitialized(e);
             //Uri targetUri = new Uri("/View/Login.xaml",System.UriKind.Relative);
             //this.principal.NavigationService.Navigate(targetUri);*   


        }

        private void Button_Click_Evenement(object sender, RoutedEventArgs e)
        {
            Uri targetUri = new Uri("/View/Event.xaml",System.UriKind.Relative);
            this.principal.NavigationService.Navigate(targetUri);
        }

        private void Button_Click_connexion(object sender, RoutedEventArgs e)
        {
            VisualStateManager.GoToElementState(this, "connected", true);
        }

        private void Button_Click_profil(object sender, RoutedEventArgs e)
        {
            Uri targetUri = new Uri("/View/Compte.xaml", System.UriKind.Relative);
            this.principal.NavigationService.Navigate(targetUri);
        }

        private void Button_Click_Contact(object sender, RoutedEventArgs e)
        {
            Uri targetUri = new Uri("/View/Contact.xaml", System.UriKind.Relative);
            this.principal.NavigationService.Navigate(targetUri);
        }

        private void Button_Click_NavigateToSubcription(object sender, RoutedEventArgs e)
        {
            VisualStateManager.GoToElementState(this, "Subcription", true);         
        }

        private void Button_Click_Subcription(object sender, RoutedEventArgs e)
        {
            MYA_WPF.Model.Personne person = new MYA_WPF.Model.Personne();
            MYA_WPF.Model.Contact contact = new MYA_WPF.Model.Contact();
            MYA_WPF.Model.User user = new MYA_WPF.Model.User();

            person.Nom = this.Nom.Text;
            person.Prenom = this.Prenom.Text;
            person.DateNaissance = this.birthday.DisplayDate;

            contact.Telephone = this.Tel.Text;
            contact.Email = this.Email.Text;
            contact.adresse = this.adresse.Text;
            contact.Relation = "O";

            user.login = this.login.Text;
            user.password = this.password.ToString();

            DataManager.subscribeUser(user, contact, person);
            VisualStateManager.GoToElementState(this, "connected", true);
        }
    }
}
